﻿
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>订单详情页面</title>
    <script src="e:\暂存空间\专业课\我的项目\第三学期\项目\b2c\shixulong.model\scripts\jquery-3.5.1.js"></script>
    <link href="~/lib/layui/css/layui.css" rel="stylesheet" />
</head>
<body>
    <form class="layui-form" @*id="frmSel"*@>
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-inline">
                <input type="text" name="userId" id="userId" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">订单编号</label>
            <div class="layui-input-inline">
                <input type="text" name="orderId" id="OrderId" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-input-inline">
                <button class="layui-btn" id="Check">查询</button>
            </div>
        </div>
    </form>
    <table id="demo" lay-filter="test"></table>
    <form class="layui-form" onsubmit="return false">
        <button id="SubShop" class="layui-btn">发货</button>
    </form>
    <script src="~/lib/layui/layui.js"></script>
    <script>
        layui.use(['table', 'form','layer'], function () {
            var table = layui.table;
            var layer=layui.layer;
            var $ = layui.$;
            //第一个实例
            table.render({
                elem: '#demo'
              , height: 312
                , id: 'idTest'
              , url: '/Order/OrderDetail?id=@Model' //数据接口
              , page: true //开启分页
              , cols: [[ //表头
                { field: 'Id', title: 'ID', width: 80, sort: true, fixed: 'left' },
                 { field: 'OrderId',  title: '订单编号', width: 90 }
                , { field: 'UserId', title: '用户名', width: 80, sort: true }
                , { field: 'ProductName', title: '付款金额', width: 80 }
                , { field: 'Picurl', title: '？？？', width: 90 }
                , { field: 'Price', title: '状态', width: 80, sort: true }
                , { field: 'CreateTime', title: '付款时间', width: 80, sort: true }
                , { field: 'DateTime', title: '订单发送时间', width: 80 }
                , { field: 'StandardsId', title: '结束时间', width: 135, sort: true }
                , { fixed: 'right', width: 200, align: 'center', toolbar: '#barDemo' } //这里的toolbar值是模板元素的选择器

              ]]
            });
            $("#Check").click(function () {
                table.reload('idTest', {
                    url: '/Order/Order'
                    , where: {
                        userId: $("#userId").val(),
                        orderId: $("#OrderId").val()
                    } //设定异步数据接口的额外参数
                    //,height: 300
                });
                return false;
            });
            $("#SubShop").click(function () {
                var con=@Model;
                console.log(con);
                $.ajax({
                    url: "/Order/SendOrder?id="+con,
                    type: "post",
                    data: con,
                    success: function (re) {
                        if (re.success>0) {
                            layer.msg(re.msg);
                        }else{
                            layer.msg(re.msg);
                        }
                    }
                });
                return false;
            });



            table.on('tool(test)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                var data = obj.data; //获得当前行数据
                var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
                var tr = obj.tr; //获得当前行 tr 的 DOM 对象（如果有的话）

                if (layEvent === 'detail') { //查看
                    //do somehing
                } else if (layEvent === 'del') { //删除
                    layer.confirm('真的删除行么', function (index) {
                        obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
                        layer.close(index);
                        //$post("/Home/Del", data, function (re) {
                        //    alert(re);
                        //}, "text");
                        $.ajax({
                            url: "/Home/Del?id="+data.Id,
                            type: "Post",
                            data: data,
                            success: function (re) {
                                alert(re);
                            }
                        });

                        //向服务端发送删除指令
                    });
                }

            });
        });
    </script>
    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-xs" lay-event="detail">查看</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
</body>
</html>